<?php

use yii\helpers\Url;

$web = Url::base();
$this->title = $tpl_info['name'];
?>

<link href="<?= $web ?>/css/card-show/card-goods-show-mobile.css" rel="stylesheet" type="text/css">

<style type="text/css">
    .duola-card .duola-title {
        background: url(<?= $web ?>/images/card-show/card-background.png) no-repeat;
        background-size: cover;
    }
</style>

<div class='main'>
    <div class="duola-card">
        <div class="duola-title">
            <img src="<?= $tpl_info['page_image_url'] ?>"/>
        </div>
        <div class="duola-goods">
            <div class="cur"></div>

        </div>

        <div id="more_btn" style="display: none;">
            <a class="btn btn-danger" style="margin:2rem; height: 1.5rem; display: block;" href="../mall-m/index?institution_code=JG000002">更多商品....</a>
        </div>
    </div>
</div>


<script type="application/javascript">
    $(function () {
        if ($("body").height() < $(window).height()) {
            $("body").height($(window).height());
        }

        $(document).scroll(function () {
            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(window).height();
            var contentHeight = $(this).height();
            if (scrollTop + scrollHeight >= contentHeight) {
                load_tj();
            }
        });
        load_tj();
    });
    var page = 0;
    var is_loading = false;
    var is_all = false;
    load_tj = function () {
        if (is_all == true) {
            return;
        }

        if (page > 20) {
            $('#more_btn').show();
            return;
        }

        if (is_loading == true) {
            return;
        }

        is_loading = true;
        requestHtml('mobile-card-goods-show-partial?card_template_id=<?=$card_template_id?>&page=' + page, null, true, function (html) {
            is_loading = false;
            $('.duola-goods').append(html);
            if (html.trim().length == 0) {
                $('#more_btn').show();
                is_all = true;
            }
            page++;
        }, function () {
            is_loading = false;
        });
    }
</script>